home *** CD-ROM | disk | FTP | other *** search
/ Champak Vol A-4 / (Vol A-4) Vol. A4.iso / Games / the-kitchen-of-doom.swf / scripts / frame_1 / DoAction.as
Text File  |  2008-03-14  |  4KB  |  133 lines

  1. stop();
  2. StringTable = function(xmlFile)
  3. {
  4.    this.table = new Array();
  5.    this.loadData(xmlFile);
  6. };
  7. StringTable.prototype.loadData = function(source)
  8. {
  9.    var _loc3_ = this;
  10.    _loc3_.xmlFile = new XML();
  11.    _loc3_.xmlFile.load(source);
  12.    _loc3_.xmlFile.ignoreWhite = true;
  13.    _loc3_.xmlFile.notify = _loc3_;
  14.    _loc3_.xmlFile.onLoad = function()
  15.    {
  16.       var stringID = "";
  17.       var _loc3_ = "";
  18.       var _loc2_ = this.firstChild.childNodes;
  19.       var _loc1_ = 0;
  20.       while(_loc1_ < _loc2_.length)
  21.       {
  22.          if(_loc2_[_loc1_].nodeName === "string")
  23.          {
  24.             stringID = _loc2_[_loc1_].attributes.id;
  25.             _loc3_ = _loc2_[_loc1_].firstChild.nodeValue;
  26.             this.notify.table[stringID] = _loc3_;
  27.          }
  28.          _loc1_ = _loc1_ + 1;
  29.       }
  30.       this.notify.loaded = true;
  31.       if(this.notify.onLoad != null)
  32.       {
  33.          this.notify.onLoad();
  34.       }
  35.       delete this;
  36.    };
  37. };
  38. StringTable.prototype["get"] = function(stringID)
  39. {
  40.    return this.table[stringID];
  41. };
  42. StringTable.prototype.populate = function()
  43. {
  44.    this.populateFieldsIn(_root);
  45. };
  46. StringTable.prototype.populateFieldsIn = function(target)
  47. {
  48.    var _loc1_ = target;
  49.    var _loc3_ = this;
  50.    for(obj in _loc1_)
  51.    {
  52.       if(_loc1_[obj] instanceof TextField)
  53.       {
  54.          if(_loc1_[obj].text.substr(0,4) == "IDS_")
  55.          {
  56.             var _loc2_ = _loc3_["get"](_loc1_[obj].text);
  57.             if(_loc2_ != null)
  58.             {
  59.                _loc1_[obj].text = _loc2_;
  60.             }
  61.          }
  62.       }
  63.       else if(_loc1_[obj] instanceof MovieClip)
  64.       {
  65.          _loc3_.populateFieldsIn(_loc1_[obj]);
  66.       }
  67.       else if(_loc1_[obj] instanceof Button)
  68.       {
  69.          _loc3_.populateFieldsIn(_loc1_[obj]);
  70.       }
  71.    }
  72. };
  73. StringTable.prototype.getBytesLoaded = function()
  74. {
  75.    return this.xmlFile.getBytesLoaded();
  76. };
  77. StringTable.prototype.getBytesTotal = function()
  78. {
  79.    return this.xmlFile.getBytesTotal();
  80. };
  81. StringTable.prototype.getPercentLoaded = function()
  82. {
  83.    var _loc1_ = this;
  84.    if(_loc1_.xmlFile.getBytesTotal() <= 0)
  85.    {
  86.       return 0;
  87.    }
  88.    var _loc2_ = Math.round(_loc1_.xmlFile.getBytesTotal() / _loc1_.xmlFile.getBytesTotal() * 100);
  89.    return _loc2_;
  90. };
  91. StringTable.prototype.dump = function()
  92. {
  93.    var _loc1_ = this;
  94.    trace("===============================");
  95.    trace(" ");
  96.    trace("Dumping the String Table:");
  97.    trace(" ");
  98.    trace("String ID                      Value");
  99.    trace("---------                      -----");
  100.    for(var _loc2_ in _loc1_.table)
  101.    {
  102.       trace(_loc2_ + "                   " + _loc1_.table[_loc2_]);
  103.    }
  104.    trace(" ");
  105.    trace("String Table dump done.");
  106.    trace("===============================");
  107.    trace(" ");
  108. };
  109. Stage.scaleMode = "noScale";
  110. Stage.showMenu = false;
  111. _quality = "HIGH";
  112. sysInfoSent = false;
  113. fpsInfoSent = false;
  114. _global.masterVolume = new Sound();
  115. restoreVolume = _global.masterVolume.getVolume();
  116. StrTable = new StringTable("kodstrings.xml");
  117. onEnterFrame = function()
  118. {
  119.    var _loc2_ = (getBytesLoaded() + StrTable.getBytesLoaded()) / (getBytesTotal() + StrTable.getBytesTotal());
  120.    var _loc1_ = int(_loc2_ * 100);
  121.    if(isNaN(_loc1_))
  122.    {
  123.       _loc1_ = 0;
  124.    }
  125.    BarInst._xscale = _loc1_;
  126.    if(getBytesTotal() > 0 && getBytesLoaded() >= getBytesTotal() && StrTable.loaded)
  127.    {
  128.       delete onEnterFrame;
  129.       gotoAndStop("Title Screen");
  130.       play();
  131.    }
  132. };
  133.